local nafeng = fk.CreateSkill{
  name = "hanqing3__nafeng",
}

Fk:loadTranslationTable{
  ["hanqing3__nafeng"] = "纳风",
  [":hanqing3__nafeng"] = "中央区移去牌时，若移去的牌数不大于你上次发动，你可以使用中央区的一张牌。",
}

local DIY = require "packages/diy_utility/diy_utility"

nafeng:addEffect(DIY.BeforeCenterAreaRemove, {
  anim_type = "drawcard",
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(nafeng.name) and #player.room:getBanner("@$CenterArea") > 0 and
      #data.ids <= player:getMark("@hanqing__nafeng")
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    local use = room:askToUseRealCard(player, {
      pattern = room:getBanner("@$CenterArea"),
      skill_name = nafeng.name,
      prompt = "#hanqing__nafeng-use",
      extra_data = {
        bypass_times = true,
        expand_pile = room:getBanner("@$CenterArea"),
        extraUse = true,
      },
      cancelable = true,
      skip = true,
    })
    if use then
      event:setCostData(self, {extra_data = use})
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:setPlayerMark(player, "@hanqing__nafeng", #data.ids)
    room:useCard(event:getCostData(self).extra_data)
  end,
})

return nafeng
